#ifndef _FN_BOX
#define _FN_BOX
#include <Arduino.h>
#include <map>

// typedef int8_t fn_id_t;
// #define MAX_NUMBER 16

class FnBox
{
public:
    FnBox(); // 默认构造函数
    bool setInterval(const char *name, uint32_t interval, std::function<void(const char *)> fn);
    void clearInterval(const char *name);
    bool hasName(const char *name);
    void scan(void);
    // void setPWM();
private:
    struct _my_callback_t
    {
        std::function<void(const char *)> fn;
        uint32_t interval;
        uint32_t last_micros;
        uint32_t next_micros;
        // const char *name;
    };
    std::map<const char *, _my_callback_t> cb_map = {};

    // _my_callback_t cb_arr[MAX_NUMBER];
    // int arr_length = sizeof(cb_arr) / sizeof(cb_arr[0]);
    // std::map<const char *, fn_id_t> name_id_map = {};

    // std::map<fn_id_t, uint32_t> cb_emit_us_map = {};
    // std::set<fn_id_t> id_set = {};
};

#endif